package data

import (
	"context"
	rv1 "review-b/api/review/v1"
	"review-b/internal/biz"

	"github.com/go-kratos/kratos/v2/log"
)

type BusinessRepo struct {
	data *Data
	log  *log.Helper
}

func NewBusinessRepo(data *Data, logger log.Logger) biz.BusinessRepo {
	return &BusinessRepo{
		data: data,
		log:  log.NewHelper(logger),
	}
}

func (r BusinessRepo) Reply(ctx context.Context, param *biz.ReplyParam) (int64, error) {
	r.log.WithContext(ctx).Infof("ReplyReview param: %v", param)
	//需要调用其他rpc服务
	ret, err := r.data.rc.ReplyReview(ctx, &rv1.ReplyReviewRequest{
		ReviewID:  param.ReviewID,
		StoreID:   param.StoreID,
		Content:   param.Content,
		PicInfo:   param.PicInfo,
		VideoInfo: param.VideoInfo,
	})
	if err != nil {
		return 0, err
	}
	return ret.ReplyID, nil
}
